<%-- 
    Document   : categorias
    Created on : 01/06/2009, 22:05:09
    Author     : Leonardo
--%>

<%@page contentType="text/html" pageEncoding="UTF-8"%>
<%@page import="com.csz.model.Categoria" %>
<%@page import="com.csz.model.Caracteristica" %>
<%@page import="java.util.List" %>
<%@page import="java.util.Iterator" %>

<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@ page isELIgnored="false"%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">

<html>
    <head>
        <link rel="stylesheet" href="css/style.css" type="text/css" charset="utf-8" />
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title>Turismo RBC @ Barnabé Solutions :: Categorias ::</title>

        <script type="text/javascript">
            function validarCampoPocentagem () {
                campo = document.getElementById('txtValorPorcentagem').value;
                if (campo > 100) {
                    alert('Valor inválido no campo Porcentagem (0% a 100%');
                    return false;
                } else {
                    return true;
                }
            }
        </script>

    </head>
    <body>
        <table align="center" cellpadding="0" cellspacing="0">
            <tr>
                <td id="logo">
                </td>
                <td valign="top">
                    <table cellpadding="0" cellspacing="0">
                        <tr>
                            <td id="nav" style="width:525px; background-image:url('imagem/header.jpg');">
                                <ul>
                                    <li class="selected" >
                                        <a href="">Home</a>
                                    </li>
                                    <li>
                                        <a href="">Login</a>
                                    </li>
                                    <li>
                                        <a href="">Paises</a>
                                    </li>
                                    <li class="last">
                                </ul>
                            </td>
                        </tr>
                        <tr>
                            <td valign="top" style="height:500px;">
                                <div id="body">
                                    <div id="body-top">
                                        <div id="body-bot">
                                            <table align="center">
                                                <tr>
                                                    <td colspan="2">
                                                        <hr>
                                                    </td>
                                                </tr>
                                                <tr>
                                                    <td align="right">
                                                        Categoria:
                                                    </td>
                                                    <td align="left">
                                                        <form name="categoria" action="ServletMain" method="POST">
                                                            <select class="lst" name="lstCategoria" onchange=submit();>
                                                                <c:choose>
                                                                    <c:when test="${setaSelecioneCategoria == true}">
                                                                        <option value="0">Selecione</option>
                                                                    </c:when>
                                                                </c:choose>
                                                                <c:forEach var="Categoria" items="${listaCategoria}">
                                                                    <option value="${Categoria.id}">${Categoria.nome}</option>
                                                                </c:forEach>
                                                                <c:choose>
                                                                    <c:when test="${setaSelecioneCategoria == false}">
                                                                        <option value="0">Selecione</option>
                                                                    </c:when>
                                                                </c:choose>
                                                            </select>
                                                            <input type="hidden" name="action" value="categoria" />
                                                        </form>
                                                    </td>
                                                </tr>
                                                <tr>
                                                    <td align="right">
                                                        Sub&nbsp;Categoria:
                                                    </td>
                                                    <td align="left">
                                                        <form name="categoriaCategoria" action="ServletMain" method="POST">
                                                            <select class="lst" name="lstSubCategoria" onchange=submit();>
                                                                <c:choose>
                                                                    <c:when test="${setaSelecioneSubCategoria == true}">
                                                                        <option value="0">Selecione</option>
                                                                    </c:when>
                                                                </c:choose>
                                                                <c:forEach var="Categoria" items="${listaSubCategoria}">
                                                                    <option value="${Categoria.id}">${Categoria.nome}</option>
                                                                </c:forEach>
                                                                <c:choose>
                                                                    <c:when test="${setaSelecioneSubCategoria == false}">
                                                                        <option value="0">Selecione</option>
                                                                    </c:when>
                                                                </c:choose>
                                                            </select>
                                                            <input type="hidden" name="action" value="subCategoria" />
                                                        </form>
                                                    </td>
                                                </tr>
                                                <form name="categoriaCategoria" action="ServletMain" method="POST">
                                                    <tr>
                                                        <td align="right">
                                                            Característica:
                                                        </td>
                                                        <td align="left">
                                                            <select class="lst" name="lstCaracteristica">
                                                                <c:choose>
                                                                    <c:when test="${setaSelecioneCaracteristica == true}">
                                                                        <option value="0">Selecione</option>
                                                                    </c:when>
                                                                </c:choose>
                                                                <c:forEach var="Caracteristica" items="${listaCaracteristica}">
                                                                    <option value="${Caracteristica.id}">${Caracteristica.nome}</option>
                                                                </c:forEach>
                                                                <c:choose>
                                                                    <c:when test="${setaSelecioneCaracteristica == false}">
                                                                        <option value="0">Selecione</option>
                                                                    </c:when>
                                                                </c:choose>
                                                            </select>
                                                        </td>
                                                    </tr>
                                                    <tr>
                                                        <td colspan="2">
                                                            <hr>
                                                        </td>
                                                    </tr>
                                                    <tr>
                                                        <td align="right">
                                                            Procentagem:
                                                        </td>
                                                        <td align="left">
                                                            <input type="text" name="txtValorPorcentagem" value="" size="3" maxlength="5"/> %
                                                        </td>
                                                    </tr>
                                                    <tr>
                                                        <td colspan="2">
                                                            <hr>
                                                        </td>
                                                    </tr>
                                                    <tr>
                                                        <td>
                                                            &nbsp;
                                                        </td>
                                                        <td align="right">
                                                            <input type="submit" value="Adicionar Caracteristica" name="btInserirValor" id="btInserirValor" class="button" onclick="return(validarCampoPocentagem());"/>
                                                        </td>
                                                    </tr>
                                                    <input type="hidden" name="action" value="gravarScore" />
                                                </form>
                                                <tr>
                                                    <td colspan="2">
                                                        <hr>
                                                    </td>
                                                </tr>
                                                <tr>
                                                    <td align="left" colspan="2">
                                                        <div class="divDuMal">
                                                            <table>
                                                                <tr class="titulo">
                                                                    <td width="340px">
                                                                        &nbsp;Categoria
                                                                    </td>
                                                                    <td width="340px">
                                                                        &nbsp;Característica
                                                                    </td>
                                                                    <td width="160px">
                                                                        &nbsp;Porcentagem
                                                                    </td>
                                                                </tr>
                                                                <c:forEach var="Score" items="${listaScore}">
                                                                    <tr class="corpo">
                                                                        <td width="340px">
                                                                            <c:out value="${Score[0]}" />
                                                                        </td>
                                                                        <td width="340px">
                                                                            <c:out value="${Score[1]}" />
                                                                        </td>
                                                                        <td width="160px">
                                                                            <c:out value="${Score[2]}" />%
                                                                        </td>
                                                                    </tr>
                                                                </c:forEach>
                                                            </table>
                                                        </div>
                                                    </td>
                                                </tr>
                                                <tr>
                                                    <td colspan="2">
                                                        <hr>
                                                    </td>
                                                </tr>
                                                <tr>
                                                    <td colspan="2" align="right">
                                                        <form name="calcularPesos" action="ServletMain" method="POST">
                                                            <input type="submit" value="Continue!" name="btContinuar" id="btContinuar" class="button"/>
                                                            <input type="hidden" name="action" value="calcularPesos" />
                                                        </form>
                                                    </td>
                                                </tr>
                                                <tr>
                                                    <td colspan="2" align="left" class="error">
                                                        <c:choose>
                                                            <c:when test="${exception != ''}">
                                                                <c:out value="${exception}"></c:out>
                                                            </c:when>
                                                        </c:choose>
                                                    </td>
                                                </tr>
                                            </table>
                                        </div>
                                    </div>
                                </div>
                            </td>
                        </tr>
                    </table>
                </td>
            </tr>
        </table>
    </body>
</html>

